# (a)
Jobs = [[None for i in range(0, 2)] for j in range(0, 99)] #M: 0,99 个数不对吧-1
NumberOfJobs = None # global 声明不用赋值
# (b)
def Initialize():
    global NumberOfJobs
    for i in range(0, 99): #M: 0,99 个数不对吧-1
        for j in range(0, 2):
            Jobs[i][j] = -1
    NumberOfJobs = 0
# (c)
def AddJob(jobNum, priority):
    global NumberOfJobs
    added = False
    index = 0
    #M： 虽然能实现 ，但有点蠢，忽略了NumberOfJobs 的作用 -1
    while not added:
        if Jobs[index] == [-1, -1]:
            Jobs[index][0] = jobNum
            Jobs[index][1] = priority
            NumberOfJobs += 1
            added = True
            print('Added')
            return
        else:
            index += 1
    print('Not added')
# (e)
def InsertionSort():
    global Jobs
    N = NumberOfJobs
    #M:这应该不是InsertionSort吧 -4
    Sorted = True
    while Sorted:
        Sorted = False
        for index in range(0, N - 1):
            if Jobs[index][1] > Jobs[index + 1][1] and Jobs[index + 1][1] != -1:
                temp = Jobs[index]
                Jobs[index] = Jobs[index + 1]
                Jobs[index + 1] = temp
                Sorted = True
        N -= 1
# (f)
def PrintArray():
    index = 0
    while Jobs[index] != [-1, -1]:
        print(Jobs[index][0], end=' ')
        print('priority ', end='')
        print(Jobs[index][1])
        index += 1

if __name__ == '__main__':
    # (d)
    Initialize()
    AddJob(12,10)
    AddJob(526, 9)
    AddJob(33, 8)
    AddJob(12, 9)
    AddJob(78, 1)
    # (g)(i)
    InsertionSort()
    PrintArray()